package com.tanhua.server.controller;

import com.tanhua.common.utils.Cache;
import com.tanhua.common.utils.UserThreadLocal;
import com.tanhua.dubbo.server.pojo.RecommendUser;
import com.tanhua.server.service.TodayBestservice;
import com.tanhua.server.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("tanhua")
//@RequestMapping("tanhua/todayBest")
@Slf4j
public class TodayBestController {
    @Autowired
    private TodayBestservice todayBestservice;

    @GetMapping("todayBest")
//    public ResponseEntity<TodayBest> queryTodayBest(@RequestHeader("Authorization") String token) {
    public ResponseEntity<TodayBest> queryTodayBest() {

        try {
            TodayBest todayBest = this.todayBestservice.queryTodayBest();

            if (null != todayBest) {
                return ResponseEntity.ok(todayBest);
            }
        } catch (Exception e) {
            log.error("查询今日佳人日志有误 userid+"+ UserThreadLocal.get().getId(), e);
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
    }


    //查询推荐用户列表

    @GetMapping("recommendation")
    @Cache
//    public ResponseEntity<PageResult> queryrecommendation(@RequestHeader("Authorization") String token,
    public ResponseEntity<PageResult> queryrecommendation(RecommendUserQueryParam queryParam) {
        try {
            PageResult pageResult = this.todayBestservice.queryrecommendation(queryParam);
            System.out.println(pageResult);
            if (null != pageResult) {
                return ResponseEntity.ok(pageResult);
            }
        } catch (Exception e) {
            log.error("查询推荐有误 userid+" + UserThreadLocal.get().getId(), e);
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
    }

}
